import {
    KanBanViewActionType,
    IKanBanViewAbility,
    IKanBanViewController,
    IKanBanViewControllerParams,
    IKanBanViewStore,
    IParam,
    IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
    getViewClassNames,
    handleQuickGroupValueChange,
    useViewAction,
    useViewBasic,
    useViewControllerParams,
    useViewProps,
} from '../use-view';

/**
 * 获取看板视图输入参数
 *
 * @export
 * @return {*}
 */
export function useKanBanViewProps() {
    return {
        ...useViewProps(),
    };
}

/**
 * 获取看板视图基础
 *
 * @export
 * @param {IKanBanViewModel} model 看板视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useKanBanViewBasic(model: any, props: IParam) {
    const getSearchFormSlotName = (props: IParam) => {
        const showTabPageExp = App.getProjectSetting().multiTabsSetting.show;
        let searchFormSlotName = 'viewHeaderTop';
        if (!showTabPageExp && props.openType == 'ROUTE') {
            searchFormSlotName = 'viewHeaderBottom';
        }
        return searchFormSlotName;
    }
    const getClassNames = (props: IParam) => {
        return getViewClassNames(model, props)
    }
    return {
        ...useViewBasic(model, props),
        getClassNames,
        getSearchFormSlotName,
        handleQuickGroupValueChange,
    };
}

/**
 * 看板视图行为
 *
 * @export
 */
export function useKanBanViewAction(controller: IKanBanViewController<IKanBanViewStore, IKanBanViewAbility>) {
    return {
        ...useViewAction(controller)
    };
}

/**
 * 获取看板视图控制器输入参数
 *
 * @export
 * @param {IKanBanViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<KanBanViewActionType, IKanBanViewAbility>>} evt
 * @return {*}  {IKanBanViewControllerParams<KanBanViewActionType, IKanBanViewAbility>}
 */
export function useKanBanViewControllerParams(
    model: any,
    props: IParam,
    evt: QXEvent<IViewEvent<KanBanViewActionType, IKanBanViewAbility>>
): IKanBanViewControllerParams<KanBanViewActionType, IKanBanViewAbility> {
    return {
        ...useViewControllerParams<IKanBanViewStore, any>(
            model,
            props,
            evt
        ),
    };
}
